<?php

/**
 * This is the model class for table "ecom_products_category".
 *
 * The followings are the available columns in table 'ecom_products_category':
 * @property string $products_category_id
 * @property string $products_category_title
 * @property string $products_category_type
 * @property string $products_category_prefix
 */
class ecom_products_category extends CActiveRecord {

    /**
     * Returns the static model of the specified AR class.
     * @return ecom_products_category the static model class
     */
    public static function model($className=__CLASS__) {
        return parent::model($className);
    }

    /**
     * @return string the associated database table name
     */
    public function tableName() {
        return 'ecom_products_category';
    }

    /**
     * @return array validation rules for model attributes.
     */
    public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('products_category_title, products_category_type', 'length', 'max' => 50),
            array('products_category_prefix', 'length', 'max' => 10),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('products_category_id, products_category_title, products_category_type, products_category_prefix', 'safe', 'on' => 'search'),
        );
    }

    /**
     * @return array relational rules.
     */
    public function relations() {
        // NOTE: you may need to adjust the relation name and the related
        // class name for the relations automatically generated below.
        return array(
            'rel_products_category_to_serial_products' => array(self::BELONGS_TO, 'sys_serial_products', 'serial_products_products_category_id'),
        );
    }

    /**
     * @return array customized attribute labels (name=>label)
     */
    public function attributeLabels() {
        return array(
            'products_category_id' => 'Products Category',
            'products_category_title' => 'Products Category',
            'products_category_type' => 'Products Category Type',
            'products_category_prefix' => 'Products Category Prefix',
        );
    }

    /**
     * Retrieves a list of models based on the current search/filter conditions.
     * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
     */
    public function search() {
        // Warning: Please modify the following code to remove attributes that
        // should not be searched.

        $criteria = new CDbCriteria;

        $criteria->compare('products_category_id', $this->products_category_id, true);
        $criteria->compare('products_category_title', $this->products_category_title, true);
        $criteria->compare('products_category_type', $this->products_category_type, true);
        $criteria->compare('products_category_prefix', $this->products_category_prefix, true);

        return new CActiveDataProvider($this, array(
                    'criteria' => $criteria,
                ));
    }

}